package com.vinaprime.primeschedule.businesslayer;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.vinaprime.primeschedule.databaselayer.VPLanguage_DL;
import com.vinaprime.primeschedule.entities.VPLanguage;

public class VPLanguage_BL {

	private VPLanguage_DL myLanguageDL;
	
	public VPLanguage_BL(Context context, String path){
		this.myLanguageDL = new VPLanguage_DL(context, path);
	}
	
	public List<VPLanguage> getAllLanguage()
	{
		List<VPLanguage> listLang = new ArrayList<VPLanguage>();
		VPLanguage lang;
		
		Cursor cur = this.myLanguageDL.getAllLanguage();
		
		if (cur.moveToFirst()) {
            do {

            	lang = new VPLanguage(); 
            	lang.setVplId(Integer.parseInt(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColId()))));
            	lang.setVplCode(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColCode())));
            	lang.setVplName(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColName())));
            	lang.setVplDescription(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColDescription())));
            	lang.setVplEnableFlag(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColEnableFlag())));

            	listLang.add(lang);
            } while (cur.moveToNext());
        }
		
		return listLang;
	}
	
	public ArrayList<VPLanguage> getAllLanguageToArray()
	{
		ArrayList<VPLanguage> listLang = new ArrayList<VPLanguage>();
		
		
		Cursor cur = this.myLanguageDL.getAllLanguage();
		
		if (cur.moveToFirst()) {
            do {

            	final VPLanguage lang = new VPLanguage(); 
            	lang.setVplId(Integer.parseInt(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColId()))));
            	lang.setVplCode(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColCode())));
            	lang.setVplName(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColName())));
            	lang.setVplDescription(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColDescription())));
            	lang.setVplEnableFlag(cur.getString(cur.getColumnIndexOrThrow(VPLanguage_DL.getDbTableColEnableFlag())));

            	listLang.add(lang);
            } while (cur.moveToNext());
        }
		
		return listLang;
	}
}
